package com.organize.entities;

import com.autumn.annotation.FriendlyProperty;
import com.autumn.audited.annotation.LogMessage;
import com.autumn.domain.entities.auditing.user.ldt.AbstractDefaultUserLdtFullAuditingEntity;
import com.autumn.mybatis.mapper.annotation.*;
import com.autumn.validation.annotation.NotNullOrBlank;
import lombok.Getter;
import lombok.Setter;
import org.apache.ibatis.type.JdbcType;
import org.hibernate.validator.constraints.Length;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 * 职员
 * <p>
 * </p>
 *
 * @description TODO
 * @author: 老码农
 * @create: 2020-10-17 14:28
 **/
@Getter
@Setter
@Table(name = "org_employee")
@TableDocument(value = "职员", group = "组织", groupOrder = 110)
public class Employee extends AbstractDefaultUserLdtFullAuditingEntity {

    private static final long serialVersionUID = 2318816696682418215L;

    /**
     *  字段 code (编号)
     */
    public static final String FIELD_CODE = "code";

    /**
     *  字段 name (名称)
     */
    public static final String FIELD_NAME = "name";

    /**
     *  字段 sex (性别)
     */
    public static final String FIELD_SEX = "sex";

    /**
     *  字段 idCard (身份证号)
     */
    public static final String FIELD_ID_CARD = "idCard";

    /**
     *  字段 departmentId (部门id)
     */
    public static final String FIELD_DEPARTMENT_ID = "departmentId";

    /**
     *  字段 postId (岗位id)
     */
    public static final String FIELD_POST_ID = "postId";

    /**
     *  字段 educationId (学历id)
     */
    public static final String FIELD_EDUCATION_ID = "educationId";

    /**
     *  字段 remarks (备注)
     */
    public static final String FIELD_REMARKS = "remarks";

    /**
     *  字段 code (编号) 最大长度
     */
    public static final int MAX_LENGTH_CODE = 20;

    /**
     *  字段 name (名称) 最大长度
     */
    public static final int MAX_LENGTH_NAME = 20;

    /**
     *  字段 sex (性别) 最大长度
     */
    public static final int MAX_LENGTH_SEX = 10;

    /**
     *  字段 idCard (身份证号) 最大长度
     */
    public static final int MAX_LENGTH_ID_CARD = 18;

    /**
     * 编号
     */
    @NotNullOrBlank(message = "编号不能为空。")
    @Length(max = MAX_LENGTH_CODE, message = "编号 不能超过 " + MAX_LENGTH_CODE + " 个字。")
    @Column(nullable = false, length = MAX_LENGTH_CODE)
    @ColumnOrder(1)
    @Index(unique = false)
    @ColumnDocument("编号")
    @FriendlyProperty(value = "编号")
    @LogMessage(order = 1)
    private String code;

    /**
     * 名称
     */
    @NotNullOrBlank(message = "名称不能为空。")
    @Length(max = MAX_LENGTH_NAME, message = "名称 不能超过 " + MAX_LENGTH_NAME + " 个字。")
    @Column(nullable = false, length = MAX_LENGTH_NAME)
    @ColumnOrder(2)
    @ColumnDocument("名称")
    @FriendlyProperty(value = "名称")
    @LogMessage(order = 2)
    private String name;

    /**
     * 性别
     */
    @NotNullOrBlank(message = "性别不能为空。")
    @Length(max = MAX_LENGTH_SEX, message = "性别 不能超过 " + MAX_LENGTH_SEX + " 个字。")
    @Column(nullable = false, length = MAX_LENGTH_SEX)
    @ColumnOrder(3)
    @ColumnDocument("性别")
    @FriendlyProperty(value = "性别")
    @LogMessage(order = 3)
    private String sex;

    /**
     * 身份证号
     */
    @Length(max = MAX_LENGTH_ID_CARD, message = "身份证号 不能超过 " + MAX_LENGTH_ID_CARD + " 个字。")
    @Column(nullable = false, length = MAX_LENGTH_ID_CARD)
    @ColumnOrder(4)
    @ColumnDocument("身份证号")
    @FriendlyProperty(value = "身份证号")
    @LogMessage(order = 4)
    private String idCard;

    /**
     * 部门id
     */
    @NotNull(message = "部门id不能为空。")
    @Column(nullable = false)
    @ColumnOrder(5)
    @Index(unique = false)
    @ColumnDocument("部门id")
    @FriendlyProperty(value = "部门id")
    @LogMessage(order = 5)
    private Long departmentId;

    /**
     * 岗位id
     */
    @NotNull(message = "岗位id不能为空。")
    @Column(nullable = false)
    @ColumnOrder(6)
    @Index(unique = false)
    @ColumnDocument("岗位id")
    @FriendlyProperty(value = "岗位id")
    @LogMessage(order = 6)
    private Long postId;

    /**
     * 学历id
     */
    @NotNull(message = "学历id不能为空。")
    @Column(nullable = false)
    @ColumnOrder(7)
    @Index(unique = false)
    @ColumnDocument("学历id")
    @FriendlyProperty(value = "学历id")
    @LogMessage(order = 7)
    private Long educationId;

    /**
     * 备注
     */
    @ColumnType(jdbcType = JdbcType.LONGVARCHAR)
    @Column(nullable = false)
    @ColumnOrder(8)
    @ColumnDocument("备注")
    @FriendlyProperty(value = "备注")
    @LogMessage(order = 8)
    private String remarks;

}
